export const taskStatus = [
    {
        value: '0',
        label: '待拜访',
    },
    {
        value: '1',
        label: '待填写',
    },
    {
        value: '2',
        label: '已完成',
    },
    {
        value: '3',
        label: '已逾期',
    },
]
export const sendType = [
    {
        value: '0',
        label: '手机',
    },
    {
        value: '1',
        label: '中台',
        selected:true
    },
]

export const taskType = [
    {
        value: '0',
        label: '个人拜访',
    },
]

export const columns = [
    {
        type: 'checkbox', //radio
        fixed: 'left',
        minWidth: 55,
        title: '',
        width: 55,
        align: "left",
        visible: true,
    },
    {
        type: 'seq',
        title: '序号',
        fixed: 'left',
        visible: true,
        minWidth: 70,
        width: 70,
        align: 'center',
    },
    {
        field: 'taskStatus',
        title: '任务状态',
        visible: true,
        minWidth: 80,
        align: 'left',
        formatter: ({ cellValue }) => {
            return getOptionsNames(cellValue, taskStatus)
        },
    },
    {
        field: 'taskType',
        title: '任务类型',
        visible: true,
        minWidth: 90,
        align: 'left',
        formatter: ({ cellValue }) => {
            return getOptionsNames(cellValue, taskType)
        },
    },
    {
        field: 'department',
        title: '部门',
        visible: true,
        minWidth: 120,
        align: 'left',
    },
    {
        field: 'director',
        title: '执行人',
        visible: true,
        minWidth: 90,
        align: 'left',
    },
    {
        field: 'customerName',
        title: '客户名称',
        visible: true,
        minWidth: 220,
        align: 'left',
    },
    {
        field: 'deadline',
        title: '截止时间',
        visible: true,
        minWidth: 100,
        formatter: ({ cellValue }) => {
            return cellValue ? dayjs(cellValue).format('YYYY-MM-DD') : ''
        },
    },
    {
        field: 'taskRequire',
        title: '任务要求',
        visible: true,
        minWidth: 200,
        align: 'left',
    },
    {
        field: 'taskSender',
        title: '任务下发人',
        visible: true,
        minWidth: 120,
        align: 'left',
    },
    {
        field: 'taskSendTime',
        title: '任务下发时间',
        visible: true,
        minWidth: 100,
        formatter: ({ cellValue }) => {
            return cellValue ? dayjs(cellValue).format('YYYY-MM-DD') : ''
        },
    },
    {
        field: 'sendType',
        title: '下发方式',
        visible: true,
        minWidth: 80,
        align: 'left',
        formatter: ({ cellValue }) => {
            return getOptionsNames(cellValue, sendType)
        },
    },
    // {
    //     field: 'operate',
    //     title: '操作',
    //     visible: true,
    //     slots: { default: 'operate' },
    //     fixed: 'right',
    //     minWidth: 180,
    //     align: "left",
    // },
]

export const flutter = [
    {
        type: 'SELECT',
        operator: '=like=',
        title: '任务状态',
        show: true,
        value: undefined,
        options: taskStatus,
        key: 'taskStatus',
        placeholder: '请选择',
    },

    {
        type: 'SELECT',
        operator: '=like=',
        title: '任务类型',
        show: true,
        value: undefined,
        options: taskType,
        key: 'taskType',
        placeholder: '请选择',
    },
    {
        type: 'INPUT',
        operator: '=like=',
        title: '部门',
        show: true,
        value: undefined,
        key: 'department',
        placeholder: '请输入',
    },
    {
        type: 'INPUT',
        operator: '=like=',
        title: '执行人',
        show: true,
        value: undefined,
        key: 'director',
        placeholder: '请输入',
        
    },
    {
        type: 'INPUT',
        operator: '=like=',
        title: '客户名称',
        show: true,
        value: undefined,
        key: 'customerName',
        placeholder: '请输入',
    },
    {
        type: 'INPUT',
        operator: '=like=',
        title: '任务要求',
        show: true,
        value: undefined,
        key: 'taskRequire',
        placeholder: '请输入',
    },
    {
        type: 'DD-DD',
        operator: '=like=',
        title: '生效时间',
        show: true,
        value: undefined,
        key: 'taskSendTime',
        placeholder: '请选择',
    },
    {
        type: 'DD-DD',
        operator: '=like=',
        title: '截止时间',
        show: true,
        value: undefined,
        key: 'deadline',
        placeholder: '请选择',
    },

    // {
    //     type: 'USER',
    //     operator: '=like=',
    //     title: '',
    //     show: true,
    //     value: undefined,
    //     key: 'executorName',
    //     placeholder: '执行人',
    // },
    // {
    //     type: 'DD-DD',
    //     operator: '=like=',
    //     title: '',
    //     show: true,
    //     value: undefined,
    //     key: 'startDate',
    //     placeholder: '开始时间',
    // },
    // {
    //     type: 'DD-DD',
    //     operator: '=like=',
    //     title: '',
    //     show: true,
    //     value: undefined,
    //     key: 'endDate',
    //     placeholder: '结束时间',
    // },
    // {
    //     type: 'DD-DD',
    //     operator: '=like=',
    //     title: '',
    //     show: true,
    //     value: undefined,
    //     key: 'endDate',
    //     placeholder: '结束时间',
    // },
]

export const batchGroup = [
    // {
    //     name: '删除',
    //     url: '/task/deleteTask',
    //     key: 'taskId',
    //     params: {},
    // },
    {
        name: '导出',
        url: '/api/zyrwSendDetail/exp',
        key: 'ids',
        params: {},
    },
]

export const setTreeData = res => {
    const computeData = menuArr => {
        menuArr.forEach(element => {
            if (element.leaf !== undefined || element.leaf !== null) {
                element.leaf = !element.leaf
            }
            if (element.children && element.children.length) {
                computeData(element.children)
            }
        })
    }
    if (res.data.length) {
        computeData(res.data)
    }
    res.data = XEUtils.toTreeArray(res.data)
    res.data.forEach(element => {
        delete element['children']
    })
    return res
}

// function updateFilterItem(key, value) {
//     const itemIndex = flutter.findIndex(item => item.key === key)
//     if (itemIndex !== -1) {
//         flutter[itemIndex].value = value
//     }
// }
